#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;

int n,m,t,T,l[N],r[N],n1 = 0x3f3f3f3f,n2,col[N];
vec G[N];

void dfs(int x,int c) {
	col[x] = c;
	for(auto y : G[x])
		if(col[y] && col[y] == c) puts("IMPOSSIBLE"),exit(0);
		else if(!col[y]) dfs(y,3 - c);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    t = in,T = in; n = in,m = in;
	rep(i, 1, n) l[i] = in,r[i] = in,n1 = min(n1,r[i]),n2 = max(n2,l[i]);
	rep(i, 1, m) {
		int x = in,y = in; G[x].pb(y); G[y].pb(x);
	}
	if(n1 + n2 > T) n1 = T - n2;
	if(n1 + n2 < t) n2 = t - n1;
	if(n1 < 0 || n2 < 0) return puts("IMPOSSIBLE"),0;
	rep(i, 1, n) {
		if(!(l[i] <= n1 && n1 <= r[i]) && !(l[i] <= n2 && r[i] >= n2)) return puts("IMPOSSIBLE"),0;
		if(l[i] <= n1 && n1 <= r[i] && !(l[i] <= n2 && r[i] >= n2)) col[i] = 1;
		else if(!(l[i] <= n1 && n1 <= r[i]) && l[i] <= n2 && r[i] >= n2) col[i] = 2;
	}
	rep(i, 1, n) if(col[i]) dfs(i,col[i]);
	rep(i, 1, n) if(!col[i]) dfs(i,1);
	puts("POSSIBLE"); cout << n1 << " " << n2 << endl;
	rep(i, 1, n) putchar(col[i] + '0'); puts(""); return 0;
}
